{#
Copyright (c) 2020 Andy Zhou
MIT License
#}
{% extends 'base.html' %}
{% block page_content %}
    <div class="nav nav-pills" role="tablist">
        <a class="nav-item nav-link {% if request.args.get('filter') != 'unread' %}active{% endif %}"
           href="{{ url_for('notification.show', filter='all') }}">
            {{ _('All') }}
        </a>
        <a class="nav-item nav-link {% if request.args.get('filter') == 'unread' %}active{% endif %}"
            href="{{ url_for('notification.show', filter='unread') }}" style="margin-right: 50px">
            {{ _('Unread') }}
        </a>
        <form method="POST" action="{{ url_for('notification.read_all') }}">
            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
            <input type="submit" class="btn btn-sm btn-light" value="{{ _('Mark all notifications as read') }}">
        </form>
    </div>
    <ul class="list-group">
        {% for notification in notifications %}
            <li class="list-group-item">
                {{ notification.message | safe }}
                {% if not notification.is_read %}
                    <form method="POST" action="{{ url_for('notification.read', id=notification.id) }}">
                        <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
                        <input type="submit" class="fa fa-square-o" value="{{ _('Mark this notification as read') }}">
                    </form>
                {% else %}
                    <span class="fa fa-check-square-o text-success"></span>
                {% endif %}
            </li>
        {% endfor %}
    </ul>
{% endblock %}